
let g:cmake_executable = get(g:, 'cmake_executable', executable('cmake')? exepath('cmake'): '')
if !executable(g:cmake_executable)
    let s:cmake_executable = 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe'
    if executable(s:cmake_executable) 
        let g:cmake_executable = s:cmake_executable
	let g:cmake_executable_path = fnamemodify(g:cmake_executable, ':p:h')
	let $PATH = g:cmake_executable_path . ';' . $PATH
    endif
endif

function! plugin#vim_cmake#load() abort
    if !exists("loaded_cmake_plugin")
        if executable(g:cmake_executable)
            packadd vim-cmake
        endif
    endif
    return exists("loaded_cmake_plugin") && g:loaded_cmake_plugin
endfunction

function! plugin#vim_cmake#init() abort
    if plugin#vim_cmake#load()
    endif
endfunction
